package net.tngou.iask.util;

import org.apache.commons.configuration2.PropertiesConfiguration;
import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
import org.apache.commons.configuration2.builder.fluent.Parameters;
import org.apache.commons.configuration2.ex.ConfigurationException;

/**
 * 取得配置文件
 * @author tngou@tngou.net
 *
 */
public class ConfigUtil {

	
	public static PropertiesConfiguration  GetConfig(String propertiesName) {
		
			try {
				Parameters params = new Parameters();
				FileBasedConfigurationBuilder<PropertiesConfiguration> builder =
				    new FileBasedConfigurationBuilder<PropertiesConfiguration>(PropertiesConfiguration.class)
				    .configure(params.properties()
				        .setFileName(propertiesName));	//那么这个文件会自动在下面几个地方被搜寻：当前目录 、用户主目录 、classpath
				PropertiesConfiguration properties = builder.getConfiguration();
				return properties;
			} catch (ConfigurationException e) {				
				e.printStackTrace();
			}
			return null;
	}
}
